package org.jeecg.modules.lab.exam.paper.service.impl;



import org.jeecg.modules.lab.exam.entity.LabExamPaperQuestion;
import org.jeecg.modules.lab.exam.entity.LabExamPaperQuestionAnswer;
import org.jeecg.modules.lab.exam.paper.mapper.LabExamPaperQuestionAnswerMapper;
import org.jeecg.modules.lab.exam.paper.mapper.LabExamPaperQuestionMapper;
import org.jeecg.modules.lab.exam.paper.service.ILabExamPaperQuestionService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: 考试记录考题表
 * @Author: jeecg-boot
 * @Date:   2023-08-30
 * @Version: V1.0
 */
@Service
public class LabExamPaperQuestionServiceImpl extends ServiceImpl<LabExamPaperQuestionMapper, LabExamPaperQuestion> implements ILabExamPaperQuestionService {
	
	@Autowired
	private LabExamPaperQuestionMapper labExamPaperQuestionMapper;
	@Autowired
	private LabExamPaperQuestionAnswerMapper labExamPaperQuestionAnswerMapper;
	
	@Override
	public List<LabExamPaperQuestion> selectByMainId(String mainId) {
		return labExamPaperQuestionMapper.selectByMainId(mainId);
	}

	@Override
	public void updateQuAnswere(String paperId, String quId,String answers) {
		labExamPaperQuestionMapper.updateQuAnswer(paperId,quId,answers);
		List<String> strs=Arrays.asList(answers.split(","));
		for(int i=0;i<strs.size();i++){
			String aid=strs.get(i);
		    LabExamPaperQuestionAnswer answer= labExamPaperQuestionAnswerMapper.selectById(aid);
			answer.setChecked("1");
			labExamPaperQuestionAnswerMapper.updateById(answer);
		}
	}
}
